<!--
Creator: Miroslav Milivojevic
-->


<?php function printHostelStars($hid){ ?>
<div class="rate_choice">
    <table>
        <?php
        require_once dirname(__FILE__) . '/db.php';
        include_once dirname(__FILE__) . '/staticStars.php';
        $conn = dbConnect("sib");

        $IDHostel = $hid;
        ?>
        
        <?php
        $query = "SELECT AVG(Security) as Security,  AVG(Location) as Location, AVG(Service) as Service, AVG(Fun) as Fun," .
                "AVG(Cleanliness) as Cleanliness, AVG(Price) as Price " .
                "FROM feedback WHERE IDHostel = $IDHostel;"; //dinamicki
        $result = mysql_query($query, $conn);
//        if (!$result)
//            echo "Error:" . mysql_error();
         
        if (!$row = mysql_fetch_array($result)){
            $row["Security"]=0;
            $row["Locastion"]=0;
            $row["Service"]=0;
            $row["Fun"]=0;
            $row["Cleanlines"]=0;
            $row["Price"]=0;
        }
        ?>
        <tr>
            <td>Security: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Security"]));
                echo $ss_security->printStars($row['Security']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Location: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Location"]));
                echo $ss_security->printStars($row['Location']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Service: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Service"]));
                echo $ss_security->printStars($row['Service']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Fun: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Fun"]));
                echo $ss_security->printStars($row['Fun']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Cleanliness: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Cleanliness"]));
                echo $ss_security->printStars($row['Cleanliness']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Price: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Price"]));
                echo $ss_security->printStars($row['Price']);
        
                ?>
            </td>
        </tr>
        
    </table>
</div>

<?php
        
}
?>
